import requests
import json

if __name__ == '__main__':

    # url = 'http://httpbin.org/post'
    # # 上传文件示例
    # files = {'file': open('D:\\demo.xls', 'rb')}
    # response = requests.post(url=url, files=files)
    # # 打印服务器响应
    # print(response.text)

    response = requests.get(
        'https://api.github.com/repos/requests/requests/git/commits/a050faf084662f3a352dd1a941f2c7c9f886d4ad')
    # 检查响应状态码是否为 200 (OK)
    if response.status_code == requests.codes.ok:
        # 打印内容类型
        print(response.headers['content-type'])

        # 解析 JSON 数据并打印部分信息
        commit_data = response.json()
        print(commit_data.keys())
        print(commit_data['committer'])
        print(commit_data['message'])

